/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.asu.cse360.client.action;

import edu.asu.cse360.client.context.RestaurantContext;
import edu.asu.cse360.client.ui.frame.LoginFrame;
import edu.asu.cse360.context.ServiceFactory;
import edu.asu.cse360.model.Table;
import edu.asu.cse360.model.TableStatus;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;

/**
 * This class is called when an employee wants to go from the customer mode to employee mode
 * @author nadimhoque
 */
public class EnterEmployeeMode extends AbstractAction{

    public EnterEmployeeMode(){
        super("Enter Employee Mode..");
    }

    public void actionPerformed(ActionEvent e) {
        LoginFrame loginFrame = LoginFrame.getLoginFrame();
        loginFrame.clearField();
        loginFrame.setVisible(true);
        Table table = RestaurantContext.getTable();
        if(table != null){
            table.setStatus(TableStatus.DIRTY);
            ServiceFactory.getTableService().save(table);
        }
    }

}
